
// init
const state = {
    TodoList: []
}
// id、标题、内容、修改时间、创建时间、选择的时间
// {id: id, title: til, content: con, time: time, create:time, date:currentDay.value.valueOf()}

// getters
const getters = {}

//actions
const actions = {
    AddTodo({commit}, todo) {
        commit('AddTodo', todo)
    },
    SetTodo({commit}, todo) {
        commit('SetTodo', todo)
    }
}

// mutations
const mutations = {
    AddTodo(state, todo) {
        state.TodoList.push(todo)
    },
    SetTodo(state, todo) {
        state.TodoList.forEach((item, index, array)=>{
            if (item.id === todo.id) {
                Object.assign(array[index], todo);
            }
        })
    }
}

export default {
    namespaced: true,
    state,
    // getters,
    actions,
    mutations
}